from PyQt4 import QtGui
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
 
from matplotlib.figure import Figure
 
class MplCanvas(FigureCanvas):
 
    def __init__(self):
        self.fig = Figure()
        self.ax = self.fig.add_subplot(111)
        super(MplCanvas, self).__init__(self.fig)
        #self.ax.set_xlim(0,600)
        #self.ax.autoscale(enable=True,axis='y',tight=False)
        self.ax.set_xlabel(r'time ($ \mu s$)')
        self.ax.set_ylabel(r'V ($mV$)') 
        FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
        FigureCanvas.updateGeometry(self)
        
class matplotlibWidget(QtGui.QWidget):
 
    def __init__(self, parent = None):
        super(matplotlibWidget, self).__init__(parent) 
        self.canvas = MplCanvas()
        self.vbl = QtGui.QVBoxLayout()
        self.vbl.addWidget(self.canvas)
        self.setLayout(self.vbl)
